﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using HWmanagementDB;

namespace HWmanagementServer
{
    [DataContract]
    public class MessageModel
    {
        [DataMember]
        public string sender;
        [DataMember]
        public string receiver;
        [DataMember]
        public string subject;
        [DataMember]
        public string messageBody;
        [DataMember]
        public int id;
        [DataMember]
        public bool is_read;

        public static MESSAGE toDBTable(MessageModel mm)
        {
            return new MESSAGE() { ID=mm.id, SENDER=mm.sender, RECEIVER=mm.receiver, SUBJECT=mm.subject, MESSAGE1=mm.messageBody, ISREAD=mm.is_read };
        }

        public static MessageModel fromDBTable(MESSAGE m)
        {
            return new MessageModel() { id=m.ID, sender=m.SENDER, receiver=m.RECEIVER, subject=m.SUBJECT, messageBody=m.MESSAGE1, is_read=m.ISREAD };
        }
    }
}
